package com.baoyouqun.domain.Enum;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SystemConfigType {
    // 每个类型备注info1~info8的用途（对应SystemConfig字段类型：info1/2=Boolean, info3/4=Integer, info5/6=BigDecimal, info7=List<String>, info8=String）
    BACKGROUND_ROLE_PERMISSION("BACKGROUND_ROLE_PERMISSION", "后台角色与权限配置", "info2:是否启用(true/false), info7:权限列表(List<String>)"),
    INVITE_FRIEND("INVITE_FRIEND", "邀请好友配置", "info1:是否赠送(true/false), info2:每日积分上限是否启用(true/false), info3:奖励积分(Integer), info4:每日上限(Integer)"),
    ADD_FRIEND("ADD_FRIEND", "添加好友配置", "info1:每日添加好友上限是否限制(true/false), info3:每日添加上限值(Integer), info8:添加好友配置（all/baoZhiHao/vip）(String)"),
    PUBLISH_POST("PUBLISH_POST", "发布帖子配置", "info1:每日发布帖子上限是否启用(true/false), info2:每日发布上限(Integer), info3:发布帖子总额上限是否启用(true/false), info4:发布总额上限(Integer), info8:发布帖子配置(all/baoZhiHao/vip)(String)"),
    NON_LEOPARD_USER_VISIT_DURATION("NON_LEOPARD_USER_VISIT_DURATION", "非豹友访问时长配置", "info2:是否限制(true/false), info3:访问时长（天）(Integer)"),
    VIP_MEMBER("VIP_MEMBER", "VIP会员配置", "info1:是否启用(true/false), info5:VIP会员价格(BigDecimal), info7:权益列表(List<VipMemberIconDTO>)"),
    VIRTUAL_CALL("VIRTUAL_CALL", "虚拟通话配置", "info2:是否开启虚拟通话服务(true/false), info7:套餐列表(List<CallPackageDTO>)"),
    // 协议类型
    USER_AGREEMENT(
            "USER_AGREEMENT",
            "用户协议",
            "info6:用户协议HTML内容(String), info3:更新时间(Integer)"
    ),
    PRIVACY_POLICY(
            "PRIVACY_POLICY",
            "隐私政策",
            "info6:隐私政策HTML内容(String), info3:更新时间(Integer)"
    ),
    REGISTRATION_BENEFITS(
            "REGISTRATION_BENEFITS",
            "豹子号注册权益",
            "info6:服务条款HTML内容(String), info3:更新时间(Integer)"
    ), SERVICE_TERMS(
            "SERVICE_TERMS",
            "豹友群会员服务协议",
            "info6:服务条款HTML内容(String), info3:更新时间(Integer)"
    ), COMPANY_PHILOSOPHY(
            "COMPANY_PHILOSOPHY",
            "公司理念",
            "info6:服务条款HTML内容(String), info3:更新时间(Integer)"
    ),
    POST_TYPE("POST_TYPE", "帖子类型配置", "info1:是否允许自定义(true/false), info8:类型列表（逗号分隔）(String)"),
    LEOPARD_NUMBER_RULE("LEOPARD_NUMBER_RULE", "豹子号规则配置", "info7:规则描述(HashMap<String,Integer>), info2:号码长度(Integer), info3:号码前缀(String)"),
    /**
     * 阿里云短信模板配置（模板ID+内容映射）
     * info8: 存储JSON格式字符串，结构为[{"templateId":"SMS_XXX","content":"模板内容"},...]
     */
    SMS_TEMPLATE(
            "SMS_TEMPLATE",
            "阿里云短信模板配置（ID+内容）",
            "info8:短信模板ID-内容映射(JSON字符串), 格式[{templateId:模板ID, content:模板内容}]"
    );
    @EnumValue
    private final String code;
    private final String desc;
    private final String fieldDesc; // 字段用途说明（同步SystemConfig字段类型）

    SystemConfigType(String code, String desc, String fieldDesc) {
        this.code = code;
        this.desc = desc;
        this.fieldDesc = fieldDesc;
    }

    // 根据code获取枚举
    public static SystemConfigType getByCode(String code) {
        for (SystemConfigType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }

    // getter方法
    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getFieldDesc() {
        return fieldDesc;
    }
}